﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
using System.IO;
using System.Collections.Generic;
using System.Text;
public partial class admin_Admin_AdminError : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

            if (!IsPostBack)
            {
                GetErr();
            }
            btnUpdate.Attributes.Add("onclick", "return confirm('确定删除" + DropDownList1.SelectedValue + "文件内容 ?')");

      
    }
    private void GetErr()
    {
        List<string> lgData = new List<string>();
        DirectoryInfo showall = new DirectoryInfo(Request.ServerVariables["APPL_PHYSICAL_PATH"] + "\\Error\\");
        foreach (FileSystemInfo f in showall.GetFileSystemInfos())
        {
            lgData.Add(f.Name);
        }
        DropDownList1.DataSource = lgData;
        DropDownList1.DataBind();
        
    }

    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        string path = Server.MapPath("~/Error/" + DropDownList1.SelectedValue);
        File.Delete(path);
        GetErr();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        TextArea1.Value = "";
        string path = Server.MapPath("~/Error/" + DropDownList1.SelectedValue);
        using (FileStream fs = File.Open(path, FileMode.Open))
        {
            byte[] b = new byte[5120];
            UTF8Encoding temp = new UTF8Encoding(true);
            while (fs.Read(b, 0, b.Length) > 0)
            {
                TextArea1.Value += temp.GetString(b);
            }
        }

    }
}
